#version 330

uniform vec3 uGradient1;
uniform vec3 uGradientD;
uniform float uGradientA;
uniform sampler1D uTexture;

out vec4 oFragColor;
in float vCoverage;
in vec2 vVertex;

void main()
{
    vec2 lPD=vVertex-uGradient1.xy;
    float B=dot(uGradientD.xy,lPD)+uGradient1.z*uGradientD.z;
    float C=dot(lPD,lPD)-uGradient1.z*uGradient1.z;
    float t=B/uGradientA+sqrt(B*B-uGradientA*C)/abs(uGradientA);
    vec4 lTex=texture(uTexture,t);
    oFragColor=vec4(lTex.rgb,lTex.a*vCoverage);
}

